package com.example.albumtype.controller;

import com.example.albumtype.entity.Albumtype;
import com.example.albumtype.service.IAlbumtypeService;
import com.example.system.log.KthLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 贾明祯
 * @ClassName AlbumtypeController
 * @Date 2020/9/22 9:19
 * @Introduce
 */
@RestController
public class AlbumtypeController {
    @Autowired
    private IAlbumtypeService albumtypeService;

    @KthLog("这个是日志功能")
    @RequestMapping("/listAlbumtype")
    public Map<String,Object> listAlbumtype() {
        Map<String,Object> returnMap = new HashMap<>();
        List<Map<String, Object>> list = new ArrayList<>();
        List<Albumtype> albumtypes = albumtypeService.listAlbumtype();
        for(Albumtype albumtype : albumtypes){
            Map<String,Object> map = new HashMap<>();
            map.put("id",albumtype.getId());
            map.put("title",albumtype.getTypeName());
            map.put("parentId",albumtype.getParentId());
            map.put("checkArr","0");
            list.add(map);
        }
        returnMap.put("data",list);
        returnMap.put("code",0);
        returnMap.put("msg","操作成功");
        return returnMap;
    }
    @RequestMapping("/mapObject")
    public void mapObject(Map<String,Object> map){

    }
}
